<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SnapAbnormal extends Model
{
    protected $table = 'snap_abnormal';

    protected $fillable = [
    	'ic_id',
    	'vehicle_number',
    	'capture_vehicle_number',
    	'capture_filename',
    	'abnormal_information',
    	'handling_situation',
    	'system_date',
    	'remark'
    ];

    public $timestamps = false;

    protected $appends = [
    	'handling_situation_desc'
    ];

    const HANDLING_SITUATION_ONE = '1';

    const HANDLING_SITUATION_ZERO = '0';

    const HANDLING_SITUATION_TWO = '2';

    public static $HANDLING_SITUATION = [
    	self::HANDLING_SITUATION_ZERO => '未处理',
    	self::HANDLING_SITUATION_ONE => '允许',
    	self::HANDLING_SITUATION_TWO => '禁止'
    ];

    public function getHandlingSituationDescAttribute(){
    	if(array_key_exists('handling_situation', $this->attributes) && $this->attributes['handling_situation'] != null){
    		return $this->attributes['handling_situation_desc'] = self::$HANDLING_SITUATION[$this->attributes['handling_situation']];
    	}
    }
}
